<?php


namespace app\common\Pay;


use App\common\Format;
use App\Models\PayExchange\PayOrderModel;

class Base
{
    protected $err = '';

    protected $config;

    public function __construct(array $config)
    {
        $this->config = $config;
    }

    /**
     * @return string
     */
    public function getErr(): string
    {
        return $this->err;
    }

    /**
     * @param $orderNo
     * @return PayOrderModel|false
     */
    protected function orderInfo($orderNo)
    {
        $order = PayOrderModel::query()->where('OrderNo', $orderNo)->first();

        if (!($order instanceof PayOrderModel)) {
            $this->err = '订单未找到';
            return false;
        }
        if ($order->OrderStatus != PayOrderModel::STATUS_INIT) {
            $this->err = '订单状态非法';
            return false;
        }
        return $order;
    }

//    protected function suc(PayOrderModel $order)
//    {
//        PayOrderModel::query()->where('OrderNo', $order->orderNo)->update([
//            'OrderStatus'=>PayOrderModel::STATUS_SUCCESS,
//            'Remark'=>'支付金额不匹配，请注意',
//            'Score'=>Format::scoreToDb($order->Amount)
//        ]);
//        $this->err = 'amount err';
//    }
}